package com.cjh.CH2;

import javax.sound.midi.Soundbank;

/**
 * @author ChenJunhong
 * @date 2018/11/23
 * Description:
 */
public class DaemonDemo {
    public static class DeamonT extends Thread {
        public void run() {
            while (true) {
                System.out.println("I am alive");

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new DeamonT();
        // 如果设置守护线程，则main线程结束以后，还会不停的打印
        thread.setDaemon(true);

        thread.start();

        Thread.sleep(2000);
    }
}
